package org.hegang.design.first.adapterpattern;

/**
 * @ClassName AudioPlayer
 * @Describe: 创建播放器
 * @Author: gang.he
 * @Email: SmileSkylife@outlook.com
 * @Date: Created in 23:08 2019/7/22
 * @Modified_By: TODO
 * @Version: V1.0
 */
public class AudioPlayer implements MediaPlayer {

    private MediaAdapter mediaAdapter;

    @Override
    public void play(String audioType, String fileName) {
        if (audioType.trim().equalsIgnoreCase("mp3")){
            System.out.println("Playing mp3 file. Name: "+ fileName);
        }else if (audioType.trim().equalsIgnoreCase("vlc") || audioType.trim().equalsIgnoreCase("mp4")){
            mediaAdapter = new MediaAdapter(audioType);
            mediaAdapter.play(audioType,fileName);
        }else {
            System.out.println("Invalid media. " + audioType + " format not supported");
        }
    }
}
